home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / Selection ƒ 2.5 / pen < prev    next >
Encoding:
Text File  |  1994-11-06  |  1.3 KB  |  58 lines  |  [TEXT/MSET]

  1. (*
  2.  
  3. Class pen is intended for subclassing for any object that draws
  4. itself on the screen and could be affected by the window's pen
  5. settings.  We default to a 1 pixel black pen.  Objects that use
  6. the pen class are easier to draw if we want a variety of pen
  7. widths, patterns, etc. without affecting other objects that use
  8. the Mac toolbox pen.
  9.  
  10. Note that any changes via size:, pattern:, or mode: *must* be followed
  11. with a set: in order to take effect.  This is done to minimize the time
  12. taken to call toolbox traps and send messages to syspat.
  13.  
  14. See IM I-474 for the Standard Pattern numbers that should be passed with
  15. the pattern: message ( 0 through 37, subtract 1 from the indices shown in IM
  16. because we wish to maintain the Mops convention of always using 0-based
  17. indexes).
  18.  
  19. *)
  20.  
  21.  
  22. :class pen super{ object }
  23.     int width
  24.     int height
  25.     int mode     \ transfer mode
  26.     int pat#  \ will be an index to the system pattern list
  27.  
  28. :m classinit:
  29.     1 put: width
  30.     1 put: height
  31.     konst patCopy put: mode
  32.     0 put: pat#    \ black
  33.     ;m
  34.  
  35. :m set:
  36.     get: pat# syspat get: ** call PenPat
  37.     get: width get: height pack  call PenSize
  38.     int: mode call PenMode ;m
  39.  
  40. \ must call setPen: after any of these for changes to take effect
  41.  
  42. :m size:  ( w h -- )
  43.     put: height put: width ;m
  44.  
  45. :m mode:  ( mode -- )
  46.     put: mode ;m
  47.  
  48. :m pattern:  ( idx -- )
  49.     put: pat# ;m
  50.  
  51. ;class
  52.  
  53. endload
  54.  
  55. *** EXAMPLE USE
  56.  
  57. See class graphicRect.
  58.